<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>当代画家作品</title>
<link href="../style/common.css" rel="stylesheet" type="text/css" />
<style type="text/css">
	.main {width:960px;margin: 0 auto;border:1px solid #cccccc;background-color: #ffffff;min-height: 450px;margin-top: 5px;}
	
	.dszp_header{position:relative;margin: 10px 0px 10px 24px;height: 20px;}
	.dszp_header span{position:absolute;right: 25px;font-family: "宋体";font-size: 12px;}
	
	.dszp_footer{position:relative;height: 20px;clear:both;margin: 0px 0px 10px 0px;}
	.dszp_footer span{position:absolute;right: 25px;font-family: "宋体";font-size: 12px;}
	
	.list{float: left;margin-left:22px;border: 1px solid #c0c0c0;display: inline;}
	.item {width: 210px; height: 250px;overflow: hidden;}
	.pic{position: relative;width: 185px;height: 225px;background: center center;margin-top: 12px;margin-left: 12px;}
	.pic a{display:block;width: 185px;height: 225px;}
	.row{margin: 0px 0px 10px 0px;overflow: hidden;}
	.nodata{display:none; height:32px; line-height:32px; text-align:center; color:#999; font-size:14px}
</style>
</head>
<body>

<%@include file="/commons/head.jsp"%>

<c:if test="${advertisementList != null}">
	<div style="border: 1px solid #ccc;background: #ffffff;margin: 0 auto;width: 960px;height: 245px;margin-top: 5px;">
		  	<%@ include file="/front/common/ad_fragment.jsp" %>
	</div>
</c:if>

	<div class="main">
	    <div style="margin: 10px 0px 0px 0px;"></div>
	   	<c:forEach items="${page.result}" var="result" varStatus="status">
			<%@ include file="/front/common/painting_fragment.jsp" %>
		</c:forEach>
	  	<div id="container" style="font-size: 14px;"></div>
    	<div class="nodata">加载数据</div> 
	</div>
	

<%@include file="/commons/foot.jsp" %>

<script type="text/javascript">

var cur_page = '${page.pageNo}';

$(function(){

	var j = 1;
	var winH = $(window).height(); //页面可视区域高度
	$(window).scroll(function () {
		var scrollT = document.documentElement.scrollTop + document.body.scrollTop;
		var pageH = $(document.body).height();
		var winH = $(window).height(); //页面可视区域高度
		var aa = (pageH-winH-scrollT)/winH;  
		if ( aa<0.02 ) {
			if (j >= 10) {
				if(cur_page < total_page){
					var next_page = cur_page+1;
					$(".nodata").show().html("别滚动了，已经到底了。。。<a href=\"${ctx}/p/paintingAction!pList_gallery.do?type=${param.type}&pageNo="+next_page+"\">下一页</a>");
				}else{
					$(".nodata").show().html("别滚动了，已经到底了。。。");
				}
				return; //控制最大只能加载10页
			}
			cur_page++;
			j++;
			getData_by_page(cur_page);
		}
	});
});

function getData_by_page(page){
	$.getJSON("${ctx}/p/paintingAction!query_ajax_gallery.do?type=${param.type}",{pageNo:page},function(json){
		if(json){
			var page = json.page;
			var arrays = json.array;
			cur_page = page.pageNo;
			total_page = page.pageCount;
			var str = "";
			$.each(arrays,function(index,array){
				if(index%4 == 0){
					str +='<div class="row">';
				}
				str += '<div class="list"><div class="item">';
				str += '<div style="background-image: url(\''+array['middleImageApath']+'\');" class="pic">';
				if(array['painterName'] != ""){
					str += '<a href="${ctx }/'+array['englishName']+'"></a>';
				}
				str += '</div></div>';
				
				str += '<div style="text-align: center;font-size: 12px;width: 208px;padding-top: 4px;">';
				if(array['painterName'] != ""){
					str += array['painterName'];
				}
				str += '&nbsp;&nbsp;<a href="${ctx}/front/backgroundAction!showDetail.do?id='+array['id']+'">'+array['title']+'</a></div>';
				
				str += '<div style="width: 208px;">';
				str += '<div style="float: left;padding: 0px 0px 0px 12px;margin-top: 10px;margin-bottom: 10px;">';
				if(array['painterName'] != ""){
					str += '<a href="${ctx }/'+array['englishName']+'"><img alt="" src="'+array['painterImagepath']+'" width="48" height="60" border="0"></a>';
				}
				str += '</div>';
				str += '<div style="padding: 0px 0px 0px 10px;font-size: 12px;float: left;margin-top: 10px;margin-bottom: 10px;">';
				str += '<p style="overflow: hidden;width: 120px;height: 22px;line-height: 22px;">';
				if(array['painterName'] != ""){
					str += '<a href="${ctx }/'+array['englishName']+'">'+array['painterName']+'</a>&nbsp;'+array['catalogType_name'];
				}
				str += '</p>';
				str+= '<p style="overflow: hidden;width: 120px;height: 22px;line-height: 22px;">';
				if(array['painterName'] != ""){
					str += array['graduatedFrom'];
				}
				str += '</p>';
				str+= '<p style="overflow: hidden;width: 120px;height: 22px;line-height: 22px;">';
				if(array['painterName'] != ""){
					str += array['honour'];
				}
				str += '</p></div>';
				str += '<div style="clear: both;"></div>';
				str += '</div>';
				
				str += '</div>';
				
                if(index == json.length -1 || (index+1) % 4 == 0){
					str +='<div style="clear: both;"></div></div>';
                }
			});
			$("#container").append(str);
		}else{
			$(".nodata").show().html("别滚动了，本页已到底。。。");
			return false;
		}
	});
}
</script>
</body>

</html>